<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
    //     function add(x,y){
    //         if(x>y){
    //             return x;
    //         }else if (x<y){
    //             return y;
    //         }else{
    //             return "两数相等";
    //         }
    //     };
    //   document.write("x和y相比较大的值是"+ add(9,20)+"<br>");
    //   document.write("x和y相比较小的值是"+ add(1,3)+"<br>");
    // function count(){
    //     var sum1 = document.getElementById("ipt1").value;
    //     console.log(sum1);
    //     var sum2 = document.getElementById("ipt2").value;
    //     console.log(sum2);
    //     var num1 = document.getElementById("ipt3").value;
    //     console.log(num1);
    //     var num = "";
    //     console.log("num===>",num);
    //     switch(num1){
    //         case"+":
    //         num = parseFloat(sum1) + parseFloat(sum2);
    //         break;
    //         case"-":
    //         num = sum1 - sum2;
    //         break;
    //         case"*":
    //         num = sum1 * sum2;
    //         break;
    //         case"/":
    //         num = sum1 / sum2;
    //         break;
    //     }
    //     document.getElementById("com").value=num;
    // }
    var score = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
    var arr= score.split(";");
    document.write(arr+"<br>"+"<br>"+"<br>");
    var sum = 0;
    for(var i = 0; i<arr.length;i++){
        sum += parseInt(arr[i].substr(arr[i].indexOf(":")+1));
        //substr()方法可以在字符串中抽取从start下标开始的指定数目的字符
        //parseInt 将字符串直接转换成整数
    }
    document.write("班级总分数为：",sum +"<br>");
    document.write("班级平均分为：",Math.round(sum/arr.length) +"<br>");


    var time = new Date();
    var weekday = ["星期天","星期一","星期二","星期三","星期四","星期五","星期六",];
        document.write(time.getFullYear()+"年"+(time.getMonth()+1)+"月"+time.getDate()+"日"+weekday[time.getDay()]);
        </script>
        <!-- <div>
            <input id="ipt1"/>
            <select  id="ipt3">
                <option>+</option>
                <option>-</option>
                <option>*</option>
                <option>/</option>
            </select>
            <input id="ipt2"/>
            <input type="button" id="ipt3" onclick="count()"  value="=">
            <input type="text" id="com">
        </div> -->
</body>
</html>